package com.cx.mall.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cx.mall.common.model.order.OrderDTO;
import com.cx.mall.common.model.order.OrderQuery;
import com.cx.mall.common.utils.ResponseVO;
import com.cx.mall.order.service.IOrderService;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderService orderService;
    @PostMapping("/save")
    public ResponseVO save(@RequestBody OrderDTO order) throws Exception {
        return ResponseVO.success(orderService.save(order));
    }

    @GetMapping("/page")
    public ResponseVO page(OrderQuery query) {
        Page page = orderService.page(query);
        return ResponseVO.success(page);
    }

    @DeleteMapping("/{id}")
    public ResponseVO removeById(@PathVariable String id) {
        orderService.removeById(id);
        return ResponseVO.success();
    }


}
